package com.example.demo.model;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

//@Configuration
public class InterceptorConfig extends WebMvcConfigurerAdapter {
	@Autowired
	private TokenInterceptor tokenInterceptor;

	public InterceptorConfig(TokenInterceptor tokenInterceptor) {
		this.tokenInterceptor = tokenInterceptor;
	}

	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		List<String> excludePath = new ArrayList<>();
		String sysUserLogin = "/dfyzapi/authority/login";
		String sign = "/dfyzapi/authority/sign";
		String hello = "/dfyzapi/authority/hello";
		String upload = "/base/pic/upload";
		excludePath.add(sysUserLogin);
		excludePath.add(sign);
		excludePath.add(hello);
		excludePath.add(upload);
		registry.addInterceptor(tokenInterceptor).excludePathPatterns(excludePath);
	}
}
